<?
require_once("mvc/action/Action.php");
require_once("cms/core/om/CategoryI18nPeer.php");

class EditAction extends Action {

    private $log;

    public function __construct() {
        $this->log =& LoggerManager::getLogger("EditAction");
    }

    public function execute(ActionConfig &$mapping, &$form, Request &$request, Response &$response) {

        if($this->log->isDebugEnabled())
            $this->log->debug("Executing category/EditAction");

        if($form->getCategoryI18n()->getCategoryI18nId() > 0) {
            $categoryI18n = CategoryI18nPeer::retrieveByPk($form->getCategoryI18n()->getCategoryI18nId());
            if(!is_null($categoryI18n)) {
                $form->setCategoryI18n($categoryI18n);
            } else {
                $this->log->error("No pageCategoryI18n found with id ".$form->getCategoryI18n()->getCategoryI18nId().".");
                $form->getCategoryI18n()->setCategoryI18nId("");
            }
        } else {

            if($form->getCategoryI18n()->getLanguageCode() === null)
                $form->getCategoryI18n()->setLanguageCode(
                    $request->getContext()->getInitParameter(_Core::DEFAULT_LANGUAGE)
                );

        }

        return $mapping->findForward("success");

    }

}
?>